/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jplurk.api;

import org.json.JSONException;
import org.json.JSONObject;

/**
 *
 * @author Jose
 */
public class PlurkUser {

    private String uid;
    
    private String userName;
    
    private JSONObject userInfo = null;

    public PlurkUser(String userName) {
        this.userName = userName;
    }

    public String getUserName() {
        return userName;
    }
 
    public JSONObject getUserInfo() {
        
        if ( this.userInfo == null ) {
            this.queryUserInfo();
        }
        
        return userInfo;
    }
        
    protected void queryUserInfo() {
        // TODO: HTTP call
    }

    public JSONObject put(String key, Object value) throws JSONException {
        
        if ( userInfo.has(key) ) {
            return userInfo.put(key, value);
        }
        else {
            throw new JSONException("The key " + key + " is not allowed in this JSON object.");
        }
    }

    public Object get(String key) throws JSONException {
        return userInfo.get(key);
    }
    
}
